home *** CD-ROM | disk | FTP | other *** search
/ Future Workshop / Future Workshop.iso / utility / cenvid / floppyin.bat < prev    next >
Encoding:
DOS Batch File  |  1994-05-23  |  1.6 KB  |  39 lines

  1. @echo off
  2. :: ***************************************************************
  3. :: *** FloppyIn.bat - Check if there is a floppy disk in drive ***
  4. :: *** ver.2          A: or B:, set ERRORLEVEL 1 if there is   ***
  5. :: ***                not, else ERRORLEVEL 0 if there is       ***
  6. :: ***************************************************************
  7.  
  8. :: CHECK FOR VALID A, B, a, or b
  9.    if "%1" == "A" GOTO VALID_DRIVE
  10.    if "%1" == "a" GOTO VALID_DRIVE
  11.    if "%1" == "B" GOTO VALID_DRIVE
  12.    if "%1" == "b" GOTO VALID_DRIVE
  13.    CEnvi printf("USAGE: FloppyIn  < A | a | B | b >\a\n") return(1)
  14.    GOTO FLOPPYIN_EXIT
  15.  
  16. :VALID_DRIVE
  17. :: Try to read a sector 3 times, return 1 if cannot read
  18.    CEnvi "#include '%0,bat,::CODE' IsFloppyIn('%1')"
  19.    ::Code  IsFloppyIn(Drive)
  20.    ::Code  {
  21.    ::Code     BLObSize(buf,5000)// prepare a big buffer
  22.    ::Code     for ( i = 0; i < 3; i++ ) {
  23.    ::Code        reg.ah = 2           // code for reading sectors
  24.    ::Code        reg.al = 1           // read one sector
  25.    ::Code        reg.ch = 0           // track number
  26.    ::Code        reg.cl = 1           // sector number
  27.    ::Code        reg.dh = 0           // disk side (0 or 1)
  28.    ::Code        reg.dl = toupper(Drive) - 'A'
  29.    ::Code        reg.es = segment(buf) // es:bx point to buffer
  30.    ::Code        reg.bx = offset(buf)
  31.    ::Code        if ( interrupt(0x13,reg,outreg) )
  32.    ::Code         exit(0)  // floppy read OK (carry flag not set)
  33.    ::Code     }
  34.    ::Code     // If finished loop without finding floppy, then error
  35.    ::Code     exit(1)
  36.    ::Code  }
  37.  
  38. :FLOPPYIN_EXIT
  39.